package org.jeecg.modules.engine.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.engine.entity.Frame;
import org.jeecg.modules.engine.entity.vo.FramePhoneVo;
import org.jeecg.modules.engine.entity.vo.FrameProcPhoneVo;
import org.jeecg.modules.engine.entity.vo.FrameVo;
import org.jeecg.modules.engine.service.IFrameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/frame")
public class FrameController {
    @Autowired
    private IFrameService frameService;
    @RequestMapping("/inPhoneList")
    public Result<?> inPhoneList(FramePhoneVo framePhoneVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
        Page<FramePhoneVo> page = new Page<FramePhoneVo>(pageNo, pageSize);
        IPage<FramePhoneVo> inPhoneList = frameService.inPhoneList(page, framePhoneVo);
        return Result.ok(inPhoneList);
    }

    @RequestMapping("/inPhoneFrameList")
    public Result<?> inPhoneFrameList(FrameProcPhoneVo frameProcPhoneVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                      @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
        Page<FrameProcPhoneVo> page = new Page<FrameProcPhoneVo>(pageNo, pageSize);
        IPage<FrameProcPhoneVo> inPhoneList = frameService.inPhoneFrameList(page, frameProcPhoneVo);
        return Result.ok(inPhoneList);
    }

    @GetMapping("/findById")
    public FrameVo findById(String id){
        return frameService.findById(id);
    }

    @PutMapping("/addTask")
    public Result<?> addTask(@RequestBody Frame frame){
        frameService.addTask(frame);
        return Result.ok();
    }

    @PutMapping("/openFrame")
    public Result<?> openFrame(@RequestBody Frame frame){
        return frameService.openFrame(frame);
    }


}
